const registerService = require('../service/registerService')
class RegisterController {
  async registerItem(ctx, next) {
    const { sportId, athleteId } = ctx.params 
    await registerService.registerItem(sportId, athleteId)
    ctx.body = {
      meta: {
        msg:'success'
      }
    }
  }
  async getRegisterList(ctx, next) {
    const { pagenum,pagesize,sportName, athleteName,sportId,athleteId } = ctx.request.body
    const res = await registerService.getRegisterList(pagenum,pagesize,sportName, athleteName,sportId,athleteId)
    ctx.body = {
      data:res
    }
  }
  async removeRegister(ctx, next) {
    const {id} = ctx.params
    await registerService.removeRegister(id)
    ctx.body = {
      msg:'success'
    }
  }
  async getRegistedItemsByAthleteId(ctx, next) {
    const { athleteId } = ctx.params
    const res = await registerService.getRegistedItemsByAthleteId(athleteId)
    ctx.body = {
      data:res
    }
  }
  async removeRegisterItem(ctx, next) {
    const { sportId, athleteId } = ctx.params
    await registerService.removeRegisterItem(sportId,athleteId)
    ctx.body = {
      msg:'success'
    }
  }
  async getRegistedItemsBySportId(ctx, next) { 
    const {sportId} = ctx.params
    const res = await registerService.getRegistedItemsBySportId(sportId)
    ctx.body = {
      data:res
    }
  }

}

module.exports = new RegisterController()